-
-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][FIX] rma_sale: Fix problems with link between RMA-sale.order and procurement.group-sale.order when creating from stock.picking.return wizard #415
base: 16.0
Are you sure you want to change the base?
Conversation
Hi @chienandalu, @pedrobaeza, |
I don't get why you need this. Can you please explain the goal of having these fields set? |
The field order_id is used for example as the inverse field in the rma_ids on sale.order, used for logic like the override of the function _get_invoiced. If you see my first commit 9787b8a there is a bug with a function name that causes it to never be called when it should set the order_id. The field sale_id on the procurement.group is used for computing the field picking_ids on sale.order and in the actual version should be set by the function _prepare_procurement_group_vals in the module rma_sale but actually it never sets it because it checks for self.order_id but the function is called with no records in self. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, for the first commit. The second one seems weird to me and I don't get your explanation. If you see, the method is not covered by tests, so it seems still not called in usual flows. Other pending points:
You have to also check pre-commit CI, and the rest of the comments inline.
Sorry for my bad explanation, I try to be more clear. When the method _prepare_procurement_group_vals is called from here rma/rma/wizard/stock_picking_return.py Line 83 in 3436ec6
the recordset in self is empty, so this condition will never be true because self.order_id will always be false: Lines 167 to 171 in 3436ec6
and this override in this case doesn't work. My commit tries to fix this case, but if it's not ok I'll try to find a cleaner solution. |
9ed0523
to
d85e072
Compare
Hi @pedrobaeza, I updated the code to be clearer, now the pre-commit CI works except for the tests. That's because the rma_sale module doesn't have a test method for the creation from stock.picking.return wizard like the one in the rma module, so the method I've added is not covered Lines 679 to 708 in 3436ec6
|
Thanks @TheClaud99. Now the code and the problem is much clearer now. I think the main problem is this call with no RMA: rma/rma/wizard/stock_picking_return.py Line 83 in 3436ec6
which is broken from the beginning. No partner is assigned as well. What about creating the RMA, and then creating the procurement group from the RMA, so the rest of the code is valid? Putting also a |
The problem is that multiple RMAs could be created from the same stock.picking.return, which, according to the current logic, all share the same procurement.group: rma/rma/wizard/stock_picking_return.py Lines 98 to 112 in 3436ec6
rma/rma/wizard/stock_picking_return.py Lines 130 to 131 in 3436ec6
Maybe the best solution could be to create the group by calling the method on the first created RMA and then set that group also to the others? |
Yes, I think the call should be done with a RMA in |
Hi @pedrobaeza, another solution I thought is to use the same logic as here (function _group_delivery_if_needed()): Lines 1121 to 1124 in 09dd76a
I just also added this line rma/rma/wizard/stock_picking_return.py Line 128 in 910e73a
to maintain the same logic as before for the group name rma/rma/wizard/stock_picking_return.py Lines 101 to 104 in 09dd76a
|
…ng from stock.picking return wizard
@pedrobaeza I also made another fix that may be added to this pr: eeb9f7f. |
This is done on purpose, as we don't want to affect the invoceability of the sales order. It's linked later. |
Ok sorry, I didn't see that it's linked later |
proc_group_vals = rmas[:1]._prepare_procurement_group_vals() | ||
proc_group_vals["name"] = self.picking_id.name | ||
proc_group = self.env["procurement.group"].create(proc_group_vals) | ||
rmas.write({"procurement_group_id": proc_group.id}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @TheClaud99 ,
IMO, the issue is due to the non-unified of procurement groups creation.
When the picking return wizard is used, one procurement group is created for all RMAs. However, this is not the case when the sales order return wizard is used or when RMAs are created manually.
#423 addresses this issue by unifying the procurement group creation at RMA confirmation, regardless of the RMA origin.
I propose you revert these changes and keep the fix of the method name in rma_sale,
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module
rma_sale
Describe the bug
There's some bugs in the rma_sale module when creating a return from the stock.picking.return wizard with the create_rma flag set.
To Reproduce
Affected versions:
Steps to reproduce the behavior:
Expected behavior
The order_id on the RMA and sale_id on the new procurement.group are set